<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/public.css" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <form class="layui-form" action="">

            <div class="layui-form-item">
                <label class="layui-form-label">医生ID</label>
                <div class="layui-input-inline">
                    <input type="text" name="doid" placeholder="请输入" autocomplete="off" class="layui-input" id="demo2">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label required">星期一 </label>
                <div class="layui-input-block">
                    <input type="radio" name="monday" value="有" title="有" checked="">
                    <input type="radio" name="monday" value="无" title="无">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">星期二 </label>
                <div class="layui-input-block">
                    <input type="radio" name="tuesday" value="有" title="有" checked="">
                    <input type="radio" name="tuesday" value="无" title="无">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">星期三 </label>
                <div class="layui-input-block">
                    <input type="radio" name="wednesday" value="有" title="有" checked="">
                    <input type="radio" name="wednesday" value="无" title="无">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">星期四 </label>
                <div class="layui-input-block">
                    <input type="radio" name="thursaday" value="有" title="有" checked="">
                    <input type="radio" name="thursaday" value="无" title="无">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">星期五 </label>
                <div class="layui-input-block">
                    <input type="radio" name="fariday" value="有" title="有" checked="">
                    <input type="radio" name="fariday" value="无" title="无">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">星期六 </label>
                <div class="layui-input-block">
                    <input type="radio" name="saturday" value="有" title="有" checked="">
                    <input type="radio" name="saturday" value="无" title="无">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">星期日 </label>
                <div class="layui-input-block">
                    <input type="radio" name="sunday" value="有" title="有" checked="">
                    <input type="radio" name="sunday" value="无" title="无">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="demo1">添加值班</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>
    </div>
</div>

<script src="/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script src="/js/jquery-3.6.0.min.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    layui.use(['form','laydate', 'tableSelect'], function () {
        var form = layui.form
            , layer = layui.layer
            , laydate = layui.laydate
            , tableSelect = layui.tableSelect;

        var $ = layui.jquery,
            table = layui.table;
        //日期
        laydate.render({
            elem: '#date'
        });
        //监听提交
        form.on('submit(demo1)', function (data) {

            //ajax 调用接口
            $.post("/api/dowork/save.do",data.field,function(res){
                if(res.code==200){
                    //新增成功
                    //关闭当前页面
                    layer.msg('新增成功！');
                    var iframeIndex = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(iframeIndex);
                }else{
                    //新增失败
                    layer.msg('新增失败！');
                }
            });
            return false;
        })


        tableSelect.render({
            elem: '#demo2',
            checkedKey: 'id',
            table: {
                url: '/api/doctor/pageWhere.do?type=1',
                cols: [[
                    { type: 'radio' },
                    { field: 'id', title: 'ID' },
                    { field: 'name', title: '姓名' },
                    { field: 'sex', title: '性别' }
                ]]
            },
            done: function (elem, data) {
                var NEWJSON = []
                layui.each(data.data, function (index, item) {
                    NEWJSON.push(item.id)
                })
                elem.val(NEWJSON.join(","))
            }
        })
    });
</script>
</body>
</html>